# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from decimal import Decimal
from typing import Union
from fastapi import Query
from pydantic import BaseModel, Field


class RefundSearchIn(BaseModel):
    """ 退款记录搜索参数 """
    page_no: int = Query(default=1, gt=0, description="当前页码")
    page_size: int = Query(default=15, gt=0, le=200, description="每页条数")
    type: Union[str, None] = Query(default=None, description="筛选类型: [all=全部,ing=退款中,ok=成功,fail=失败]")
    user: Union[str, None] = Query(default=None, description="用户信息")
    scene: Union[str, None] = Query(default=None, description="退款场景")
    refund_sn: Union[str, None] = Query(default=None, description="退款单号")
    order_sn: Union[str, None] = Query(default=None, description="来源单号")
    start_time: Union[int, str, None] = Query(default=None, description="开始时间")
    end_time: Union[int, str, None] = Query(default=None, description="结束时间")


class RefundAgainIn(BaseModel):
    """ 重新退款参数 """
    id: int = Field(..., ge=0, description="记录ID")


"""--------------- Separator ---------------"""


class RefundListVo(BaseModel):
    """ 退款记录列表Vo """
    id: int = Field(description="文章ID")
    refund_sn: str = Field(description="充值单号")
    order_sn: str = Field(description="充值单号")
    total_amount: Decimal = Field(description="订单金额")
    refund_amount: Decimal = Field(description="退款金额")
    refund_status: int = Field(description="退款状态: [0=未退款, 1=退款中, 2=退款成功, 3=退款失败]")
    create_time: str = Field(description="创建时间")
    user: dict = Field(default="用户信息")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 2,
                "refund_sn": "202410292334581186",
                "order_sn": "202407251742446451",
                "total_amount": 0.01,
                "refund_amount": 0.01,
                "refund_status": 0,
                "create_time": "2023-09-18 21:46:21",
                "user": {
                    "sn": "80965941",
                    "avatar": "http://0.0.0.0:8100/xiao.png",
                    "mobile": "13800138000",
                    "nickname": "xiao"
                }
            }
        }
